package com.lxy.dataservice.service;

import com.lxy.dataservice.dao.SoldNoteDao;
import com.lxy.dataservice.entity.SoldNote;
import com.nip.db.mongodb.utils.Page;
import com.nip.db.mongodb.utils.PageExamplePackag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * SoldNoteService
 *
 * @author < a href=" ">ZhangYang</ a>
 * @version v1.0.01
 * @date 2020-01-07 17:04
 */
@Service
public class SoldNoteService {
  @Autowired
  SoldNoteDao soldNoteDao;

  /**
   * 查找所有销量记录
   */
  public List<SoldNote> findAllSoldNote(Page page) {
    SoldNote soldNote = null;
    PageExamplePackag<SoldNote> pep = new PageExamplePackag<>(soldNote,page);
    if (soldNote != null && null != page){
      return soldNoteDao.findAll(pep.getExample(),pep.getPageable()).getContent();
    }
    if (null != soldNote){
      return soldNoteDao.findAll(pep.getExample());
    }else {
      return soldNoteDao.findAll(pep.getPageable()).getContent();
    }
  }

  /**
   * 根据开始结束时间查找销售记录
   */

  public List<SoldNote> findAllSoldNoteByUpdateTimeBetween(String from,String to) {
    return soldNoteDao.findAllByUpdateTimeBetween(from,to);
  }
}
